package com.nbjtjc.safe.api.emg;

import com.nbjtjc.safe.annotation.SysLog;
import com.nbjtjc.safe.api.AbstractController;
import com.nbjtjc.safe.bean.Page;
import com.nbjtjc.safe.bean.Result;
import com.nbjtjc.safe.model.emg.EmgWorkBrief;
import com.nbjtjc.safe.service.emg.EmgWorkBriefService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 应急工作简报
 */
@RequestMapping("/workBrief")
@CrossOrigin("*")
@RestController
public class EmgWorkBriefController extends AbstractController<EmgWorkBrief> {

    @Autowired
    private EmgWorkBriefService emgWorkBriefService;

    @Override
    @RequestMapping(value = "/delete",method = {RequestMethod.POST})
    @SysLog("删除应急工作情况简报")
    public Result delete(int id) {
        Result result=new Result();
        try {
            result=emgWorkBriefService.delete(id);
        } catch (Exception e) {
            e.printStackTrace();
            result.setFalse(e.getMessage());
        }
        return result;
    }

    @Override
    @RequestMapping(value = "/find",method = {RequestMethod.POST,RequestMethod.GET})
    public Result find(  EmgWorkBrief emgWorkBrief,Page page) {
        Result result=new Result();
        try {
            result=emgWorkBriefService.find(emgWorkBrief,page);
        } catch (Exception e) {
            e.printStackTrace();
            result.setFalse(e.getMessage());
        }
        return result;
    }

    @RequestMapping(value = "/findBriefOrganize",method = {RequestMethod.POST})
    public Result findBriefOrganize(EmgWorkBrief emgWorkBrief, Page page){
        Result result=new Result();
        try {
            result=emgWorkBriefService.findOrganize(emgWorkBrief,page);
        } catch (Exception e) {
            e.printStackTrace();
            result.setFalse(e.getMessage());
        }
        return result;
    }
    @RequestMapping(value = "/findLowerLevelWorkBrief",method = {RequestMethod.POST})
    public Result findLowerLevelWorkBrief(EmgWorkBrief emgWorkBrief) {
        Result result=new Result();
        try {
            result=emgWorkBriefService.findLowerLevelWorkBrief(emgWorkBrief);
        } catch (Exception e) {
            e.printStackTrace();
            result.setFalse(e.getMessage());
        }
        return result;
    }
    @RequestMapping(value = "/add",method = {RequestMethod.POST,RequestMethod.GET})
    @SysLog("添加应急工作情况简报")
    public Result add(EmgWorkBrief emgWorkBrief) {
        Result result=new Result();
        try {
            result=emgWorkBriefService.add(emgWorkBrief);
        } catch (Exception e) {
            e.printStackTrace();
            result.setFalse(e.getMessage());
        }
        return result;
    }
    @RequestMapping(value = "/update",method = {RequestMethod.POST,RequestMethod.GET})
    @SysLog("更新应急工作情况简报")
    public Result update(EmgWorkBrief emgWorkBrief) {
        Result result=new Result();
        try {
            result=emgWorkBriefService.update(emgWorkBrief);
        } catch (Exception e) {
            e.printStackTrace();
            result.setFalse(e.getMessage());
        }
        return result;
    }

}
